#include "istrategy.h"
#include <stdlib.h>

struct IStrategy *strategys = NULL;
int nr_strategy = 0;

void RegisterStrategy(struct IStrategy s)
{
    if (strategys == NULL) {
        strategys = (struct IStrategy *)malloc(sizeof *strategys);
        strategys[0] = s;
        nr_strategy = 1;
    } else {
        nr_strategy++;
        struct IStrategy *s = (struct IStrategy *)realloc(strategys, nr_strategy * sizeof *strategys);
        if (s != NULL) {
            strategys = s;
        }
    }
}

void ForeachStrategy(void (*fn)(struct IStrategy *s))
{
    for (int i = 0; i < nr_strategy; i++) {
        fn(&strategys[i]);
    }
}
